<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .active {
      color: #fff;
      background-color: #f80;
      font-size: 25px;
    }
  </style>
</head>

<body>
  <div class="box">
    我是box
  </div>
  <button class="btn">切换</button>
  <script>
    var boxEl = document.querySelector('.box')
    var btnEl = document.querySelector('.btn')
    boxEl.className = 'abc'
    boxEl.classList.add('abc')
    boxEl.classList.add('active')
    boxEl.classList.remove('abc')
    btnEl.onclick = function () {
      // if (boxEl.classList.contains('active')) {
      //   boxEl.classList.remove("active")
      // } else {
      //   boxEl.classList.add("active")
      // }

      boxEl.classList.toggle("active")
    }

  </script>
</body>

</html>